#include <stdio.h>
#define M 5
#define N 3

int main() {
	int a[N][M], n, m, t, i;
	for (m = 0; m < N; m++)
		for (n = 0; n < M; n++) {
			scanf("%d", &t);
			if (t == 2)
				a[m][n] = 0;
			else {
				for (i = 2; i < t; i++) {
					if (t % i == 0) {
						a[m][n] = 1;
						break;
					}
					if (i == t - 1)
						a[m][n] = 0;
				}
			}
		}
	for (m = 0; m < N; m++) {
		for (n = 0; n < M; n++)
			printf("%d\t", a[m][n]);
		printf("\n");
	}
}